/*
 * Basic component library: straight waveguides.
 *
 * Copyright (c) 1993-2010 Leo Spiekman, Xaveer Leijtens
 *
 * This file is part of libMask.
 *
 * libMask is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * libMask is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with libMask.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "mask.h"

#define VERYSMALL   (1.0e-12)

void sw(double l, double w)
{
  double l_extra;

  if (fabs(l) < VERYSMALL) return;
  if (fabs(w) < VERYSMALL) {
    skip(l);
    return;
  }

  l_extra = copysign(sw_overlap, l*sw_overlap);

  skip(-l_extra);
  rect(l+2*l_extra,w,4,6);
  skip(-l_extra);
}

/* Draw two waveguides of length l, width w spaced by g.
 */
void sw2(double l, double w, double g)
{
 double w_tot;         /* total width of the block*/
 w_tot = 2 * w + g;
 
    movept(l, w_tot, 4, 7);
    rect(l, w, 7, 7);
    movept(l, w_tot, 7, 1);
    rect(l, w, 1, 1);
    movept(l, w_tot, 1, 6);
}

